package com.cy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/consumer/feign/")
public class FeignConsumerController {
    @Autowired
    private ConsumerHttpApi consumerHttpApi;

    //http://localhost:8090/consumer/feign/hello
    @GetMapping("{string}")
    public String doEcho(@PathVariable String string){
        return consumerHttpApi.doEcho(string);
    }
}

@FeignClient("nacos-provider")//nacos-providers为服务提供者名称
@RestController
interface ConsumerHttpApi{
    @GetMapping("/provider/echo/{string}")
    String doEcho(@PathVariable(value="string") String string);
}